package com.iot.manage.service;

import com.alibaba.fastjson.JSONObject;
import com.iot.manage.dao.UserMapper;
import com.iot.manage.pojo.App;
import com.iot.manage.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public List<User> findUsersInfo(String query, int pagenum, int pagesize) {
        return userMapper.findUsersInfo(query,pagesize * (pagenum - 1),pagesize * pagenum);
    }

    public int countUsersInfo(String query) {
        return userMapper.countUsersInfo(query);
    }

    public void deleteUserInfo(String id) {
        userMapper.deleteUserInfo(id);
    }

    public void addUserInfo(JSONObject params) {
        userMapper.addUserInfo(params);
    }

    public User findUserInfo(String param) {
        return userMapper.findUserInfo(param);
    }

    public void updateUserInfo(JSONObject params) {
        userMapper.updateUserInfo(params);
    }

    public List<User> findUsersAccess() {
        return userMapper.findUsersAccess();
    }

    public List<App> findAppsOfAllot() {
        return userMapper.findAppsOfAllot();
    }

    public List<String> findAppsOfAllotByUser(String userId) {
        return userMapper.findAppsOfAllotByUser(userId);
    }

    public void deleteAppsOfAllotByUser(String userId) {
        userMapper.deleteAppsOfAllotByUser(userId);
    }

    public void addAppsOfAllotByUser(List<Map<String, String>> list) {
        userMapper.addAppsOfAllotByUser(list);
    }

    public void deleteRelevancy(String userId) {
        userMapper.deleteRelevancy(userId);
    }
}
